package cn.fl.ass.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.ass.service.IAssTrailCarHvService;
import cn.fl.ass.transform.AssTrailCarHvVOTransform;
import cn.fl.ass.vo.AssTrailCarHvVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import fl.ass.facade.api.IAssTrailCarHvApi;
import fl.ass.facade.condition.AssTrailCarHvQueryCondition;
import fl.ass.facade.dto.AssTrailCarHvDTO;
import fl.ass.facade.dto.MessageDTO;

/**
 * @Description: 拖车交接单 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class AssTrailCarHvServiceImpl implements IAssTrailCarHvService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(IAssTrailCarHvService.class);
	
	/**
	 * TODO 自定义 API 暴露交接单服务
	 */
	@Autowired
	private IAssTrailCarHvApi assTrailCarHvApi;

	@Override
	public AssTrailCarHvVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			return null;
		}
		//TODO 业务逻辑
		AssTrailCarHvDTO dto = null;//this.自定义ApiService.selectById(id);
		return AssTrailCarHvVOTransform.toVO(dto);
	}

	@Override
	public Long add(AssTrailCarHvVO entity) throws BaseException{
		if(null == entity){
			return null;
		}
		//返回新增ID值-JL-20170320
		MessageDTO<String> response = this.assTrailCarHvApi.saveAssTrailCarHv(AssTrailCarHvVOTransform.toDTO(entity));
		return response.getId();
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			return false;
		}
		//return this.assTrailCarHvApiService.removeById(id);
		//TODO 业务逻辑
		return false;
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
    	if(CollectionUtils.isEmpty(ids)){
			return false;
		};
		return false;
    }

	@Override
	public boolean modify(AssTrailCarHvVO entity) throws BaseException{
		if(null == entity){
			return false;
		}
		//返回逻辑值-JL-20170405
		MessageDTO<String> response = this.assTrailCarHvApi.updateAssTrailCarHv(AssTrailCarHvVOTransform.toDTO(entity));
		return response.isSuccess();
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		return this.assTrailCarHvApi.findAssTrailCarHvListByPage(page);
	}
	
	/**
	 * 不分页查询拖车交接单
     * @param condition
     * @return
	 */
	@Override
	public List<AssTrailCarHvVO> searchList(AssTrailCarHvQueryCondition condition) throws BaseException {
		if(null == condition){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"查询对象不能为空!");
		}
		List<AssTrailCarHvDTO> list = this.assTrailCarHvApi.searchHvList(condition);
		return AssTrailCarHvVOTransform.toVOList(list);
	}
}
